package com.jungle.client;

import com.jungle.client.control.BasicDialog;
import javafx.fxml.FXML;
import javafx.scene.control.TextField;
import lombok.extern.slf4j.Slf4j;

import java.io.IOException;
import java.net.URL;
import java.util.function.Consumer;

import static com.jungle.client.FxApplication.bundle;

@Slf4j
public class PopupController extends BasicDialog<String> {
    @FXML
    private TextField url;

    @Override
    protected void loadData(String dataSetVo) {
        url.setText(dataSetVo);
    }

    @Override
    protected String storeData() {
        return url.getText();
    }
    private static final URL FXML_URL = DatasetItemEditController.class.getResource("popup.fxml");

    public static void showAddDialog(String dataSetVo, Consumer<String> consumer) throws IOException {

        String title = bundle.getString("apiUrl.title");

        new PopupController().showDialog(FXML_URL, title, dataSetVo, consumer);
    }

}
